Cracking the Coding Interview. (2500+ Interview Que. & Ans.) by Harry - Anonymous Hacktivist

Cracking the Coding Interview. (2500+ Interview Que. & Ans.) by Harry - Anonymous Hacktivist

Author:Harry - Anonymous Hacktivist.
Language: eng
Format: epub
Tags: Cracking The Coding Interview, Cracking The Programming Interview, Cracking The Interview, Cracking The Java Interview, JOB Interview, Interview, JAVA Programming
Publisher: Harry & Associates.
Published: 2014-07-28T00:00:00+00:00


Question What does the "final" keyword mean in front of a variable? A method? A class? (Core Java)

Answer FINAL for a variable : value is constant.

FINAL for a method : cannot be overridden.

FINAL for a class : cannot be derived .

Question What is the difference between instanceof and isInstance?

Answer instanceof is used to check to see if an object can be cast into a specified type without throwing a cast class exception. isInstance() Determines if the specified Object is assignment-compatible with the object represented by this Class. This method is the dynamic equivalent of the Java language instanceof operator. The method returns true if the specified Object argument is non-null and can be cast to the reference type represented by this Class object without raising a ClassCastException. It returns false otherwise.

Question Why does it take so much time to access an Applet having Swing Components the first time? (Swing)

Answer Because behind every swing component are many Java objects and resources. This takes time to create them in memory. JDK 1.3 from Sun has some improvements which may lead to faster execution of Swing applications.

Question How do I include static files within a JSP page? (JSP)

Answer Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. The following example shows the syntax: Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.

Question Why does JComponent have add() and remove() methods but Component does not? (Swing)

Answer because JComponent is a subclass of Container, and can contain other components and jcomponents.

Question How would you create a button with rounded edges? (Swing)

Answer There are 2 ways. The first thing is to know that a JButton?s edges are drawn by a Border. so you can override the Button?s paintComponent(Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button?s border to it.

Question How would you detect a keypress in a JComboBox? (Swing)

Answer Add a KeyListener to the JComboBox?s editor component instead of adding a KeyListener to the JComboBox itself.

Question Why should the implementation of any Swing callback (like a listener) execute quickly? (Swing)

Answer Because callbacks are invoked by the event dispatch thread which will be blocked processing other events for as long as your method takes to execute.

Question Why would you use SwingUtilities.invokeAndWait or SwingUtilities.invokeLater? (Swing)

Answer I want to update a Swing component but I?m not in a callback. If I want the update to happen immediately (perhaps for a progress bar component) then I?d use invokeAndWait. If I don?t care when the update occurs, I?d use invokeLater.

Question If your UI seems to freeze periodically, what might be a likely reason? Answer A callback implementation like ActionListener.actionPerformed or MouseListener.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.